// 写一个文件中的完整的Sphere(球体)程序， 成员函数定义在类声明中
// 球体面积 = 4.0 * M_PI * pow(r, 2);
// 球体体积 = 4.0 * M_PI * pow(r, 3) / 3.0;

#include <iostream>
#include <math.h>
using namespace std;

class Sphere {
private:
    double radius;
    double area;
    double volume;

public:
    void SetRadius(double r) { radius = r; }

    void CalcSurfaceArea() {
        area = 4.0 * M_PI * pow(radius, 2);
    }

    void CalcVolume() {
        volume = 4.0/3.0 * M_PI * pow(radius, 3);
    }

    void PrintSphere() {
        cout << "球的数据为:\n"
            << "半径 = " << radius << "\n"
            << "表面积 = " << area << "\n"
            << "体积 = " << volume << "\n";
    }
};

int main() {
    cout << "欢迎使用Sphere程序!\n";

    Sphere sphere;
    sphere.SetRadius(5.0);
    sphere.CalcSurfaceArea();
    sphere.CalcVolume();
    sphere.PrintSphere();
}
